package Package.StreamStream.StreamStreamGenerationMode;

import java.util.*;
import java.util.stream.Stream;

public class StreamStreamGenerationMode {
    public static final void StreamStreamGenerationMode(){
//生成Stream流的方式
//Collection体系集合
//使用默认方法stream()生成流， default Stream stream()
//Map体系集合
//把Map转成Set集合，间接的生成流
//数组
//通过Stream接口的静态方法of(T... values)生成流
        //Collection体系的集合可以使用默认方法stream()生成流
        List<String> list=new ArrayList<String>();
        Stream<String> listStream=list.stream();
        Set<String> set=new HashSet<String>();
        Stream<String> setStream=set.stream();
//        //Map体系的集合间接的生成流
        Map<String,Integer> map=new HashMap<String, Integer>();
        Stream<String> keyStream=map.keySet().stream();
        Stream<Map.Entry<String, Integer>> entryStream=map.entrySet().stream();
//        数组可以通过Stream接口的静态方法of(T... values)生成流
        String[] strArray = {"hello","world","java"};
        Stream<String> strArrayStream=Stream.of(strArray);
        Stream<String> stringStream2=Stream.of("hello","world","java");
        Stream<Integer> integerStream=Stream.of(10,20,30,200,100,500,4156484);
        integerStream.forEach(System.out::println);
    }
}
